from PyQt4 import QtGui, QtCore; #@UnusedImport

class Settings_InfoDisplay(QtCore.QObject):    
    def __init__(self, parent):
        super(Settings_InfoDisplay, self).__init__();
        self.parent = parent;
        self.mainWin = parent.mainWin;
        self.graphScene = parent.graphScene;
        self.createSettings_InfoDisplay();
        
    def onCbxStateClick(self, iVal):
        self.graphScene.graphView.setNodes_StyleInfo(iVal);
        
    def onCbxEdgeClick(self, iVal):
        iVal = 0 if iVal <= 2 else 1;
        self.graphScene.graphView.setEdges_StyleInfo(iVal);
        
    def onCbxActionClick(self, iVal):
        self.graphScene.graphView.setActions_StyleInfo(iVal);
            
    def updateSelectedSettings(self):
        self.onCbxStateClick(self.cbxState.currentIndex());
        self.onCbxEdgeClick(self.cbxEdge.currentIndex());
        self.onCbxActionClick(self.cbxAction.currentIndex());
        
    def createSettings_InfoDisplay(self):
        self.lblState = QtGui.QLabel("State:", self.mainWin);
        self.lblEdge = QtGui.QLabel("Edge:", self.mainWin);
        self.lblAction = QtGui.QLabel("Action:", self.mainWin);
        self.cbxState = QtGui.QComboBox(self.mainWin);
        self.cbxState.addItems(["All Info", "Reward", 
                                "Value", "Distance",
                                "Only Reward", "Only Value", 
                                "Only Distance", "Only State Dims", "No Info"]);
        self.cbxState.connect(self.cbxState, 
                              QtCore.SIGNAL("currentIndexChanged(int)"), 
                              self.onCbxStateClick);
        self.cbxState.setMaximumWidth(100);
        self.cbxState.setMinimumWidth(100);
        self.cbxEdge = QtGui.QComboBox(self.mainWin);
        self.cbxEdge.addItems(["All Info", "Only Probability", 
                               "Only Reward", "No Info"]);
        self.cbxEdge.connect(self.cbxEdge, 
                               QtCore.SIGNAL("currentIndexChanged(int)"), 
                               self.onCbxEdgeClick);
        self.cbxEdge.setMaximumWidth(100);
        self.cbxEdge.setMinimumWidth(100);
        self.cbxAction = QtGui.QComboBox(self.mainWin);
        self.cbxAction.addItems(["Only Q", "Only Id", "No Info"]);
        self.cbxAction.connect(self.cbxAction, 
                               QtCore.SIGNAL("currentIndexChanged(int)"), 
                               self.onCbxActionClick);
        self.cbxAction.setMaximumWidth(100);
        self.cbxAction.setMinimumWidth(100);
        
        
        self.gridLayout = QtGui.QGridLayout();
        self.gridLayout.addWidget(self.lblState,0,0, 
                                  QtCore.Qt.AlignRight);        
        self.gridLayout.addWidget(self.cbxState,0,1, QtCore.Qt.AlignLeft);
        self.gridLayout.addWidget(self.lblEdge,1,0, 
                                  QtCore.Qt.AlignRight);        
        self.gridLayout.addWidget(self.cbxEdge,1,1, QtCore.Qt.AlignLeft); 
        self.gridLayout.addWidget(self.lblAction,2,0, 
                                  QtCore.Qt.AlignRight);
        self.gridLayout.addWidget(self.cbxAction,2,1, QtCore.Qt.AlignLeft);
        
        self.qWidget = QtGui.QWidget(self.mainWin);
        self.qWidget.setLayout(self.gridLayout);
        self.vBoxMain = QtGui.QVBoxLayout();
        self.vBoxMain.addWidget(self.qWidget); 
        
         
#    def setInfoStyleSt_AllInfo(self):
#        self.graphScene.graphView.setNodes_StyleInfo(0);
#    def setInfoStyleSt_HideV(self):
#        self.graphScene.graphView.setNodes_StyleInfo(1);    
#    def setInfoStyleSt_HideR(self):
#        self.graphScene.graphView.setNodes_StyleInfo(2);      
#    def setInfoStyleSt_OnlyR(self):
#        self.graphScene.graphView.setNodes_StyleInfo(3);
#    def setInfoStyleSt_OnlyV(self):
#        self.graphScene.graphView.setNodes_StyleInfo(4);
#    def setInfoStyleSt_OnlyDim(self):
#        self.graphScene.graphView.setNodes_StyleInfo(5);
#    def setInfoStyleSt_NoInfo(self):
#        self.graphScene.graphView.setNodes_StyleInfo(6);
#    def setInfoStyleEdge_AllInfo(self):
#        self.graphScene.graphView.setEdges_StyleInfo(0);
#    def setInfoStyleEdge_OnlyProb(self):
#        self.graphScene.graphView.setEdges_StyleInfo(0);
#    def setInfoStyleEdge_NoInfo(self):
#        self.graphScene.graphView.setEdges_StyleInfo(1);
#    def setInfoStyleAct_OnlyQ(self):
#        self.graphScene.graphView.setActions_StyleInfo(0);   
#    def setInfoStyleAct_OnlyId(self):
#        self.graphScene.graphView.setActions_StyleInfo(1);
#    def setInfoStyleAct_NoInfo(self):
#        self.graphScene.graphView.setActions_StyleInfo(2);

        
    def getDataSettings(self):
        aDataSettings = [];
        aDataSettings.append(self.cbxState.currentIndex());
        aDataSettings.append(self.cbxEdge.currentIndex());
        aDataSettings.append(self.cbxAction.currentIndex());
        return aDataSettings;
    
    def setDataSettings(self, aDataSettings):
        self.cbxState.setCurrentIndex(aDataSettings[0]);
        self.cbxEdge.setCurrentIndex(aDataSettings[1]);
        self.cbxAction.setCurrentIndex(aDataSettings[2]);
        self.updateSelectedSettings();
